package com.ruike.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author 吴泽胜
 * @FileName MyConfig
 * @date 2021-01-07 11:24 下午
 * @Software: IntelliJ IDEA
 */

@Configuration
public class ResourcesConfiguration implements WebMvcConfigurer {

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        // 首页,暂时更新
        registry.addViewController("/").setViewName("index");
        // 登陆
        registry.addViewController("/login.html").setViewName("login");
        // 登出
        registry.addViewController("/index.html").setViewName("index");

        // 登陆成功，进入管理首页
        registry.addViewController("/success.html").setViewName("view/index");
        // 个人信息
        registry.addViewController("/profile.html").setViewName("view/profile");
        // 教学楼管理
        // registry.addViewController("/view/academic_building.html").setViewName("view/academic_building");

    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // html静态文件路径
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        // 解决swagger无法访问
        registry.addResourceHandler("/swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
        // 解决swagger的js文件无法访问
        registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
    }
}
